package com.example.demo;

import com.example.demo.enable.EnableUser;
import com.example.demo.listen.TestListener;
import com.example.demo.model.User;
import org.springframework.boot.Banner;
import org.springframework.boot.ImageBanner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

/**
 * @author yujie
 */
@SpringBootApplication(scanBasePackages = {"com.example.demo"})
@EnableCaching
public class DemoApplication {


    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(DemoApplication.class);
        application.setBannerMode(Banner.Mode.CONSOLE);
        Resource resource = new ClassPathResource("logo.jpg");
        ImageBanner imageBanner = new ImageBanner(resource);
        application.setBanner(imageBanner);
        application.addListeners(new TestListener());
        /**
         * run 顺序
         * 1、通知 starting 事件
         * 2、通知 environment prepared 事件
         * 3、
         *
         */
        ConfigurableApplicationContext configurableApplicationContext = application.run(args);

        System.out.println(configurableApplicationContext.getBean(User.class));
    }
}
